package week3;

/**
 * Created by dell on 2017/3/10.
 */
class CashCard1 {
    String number;
    int balance;
    int bonus;
    CashCard1(String number, int balance, int bonus){
        this.number = number;
        this.balance = balance;
        this.bonus = bonus;
    }

    void store(int money) {
        if(money > 0){
            this.balance += money;
            if(money >= 1000) {
                this.bonus ++;
            }

        }
        else {
            System.out.println("存储必须为正！");
        }
    }

    void charge(int money) {
        if(money > 0) {
            if(money <= this.balance) {
                this.balance -= money;
            }
            else{
                System.out.println("金额不足");
            }
        }
        else {
            System.out.println("不足扣取");
        }
    }

    int exchange(int bonus){
        if(bonus > 0) {
            this.bonus -= bonus;
        }
        return this.bonus;
    }
}
